package com.likl.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.convert.DataSizeUnit;
import org.springframework.boot.convert.DurationUnit;
import org.springframework.stereotype.Component;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Max;
import java.time.Duration;
import java.time.temporal.ChronoUnit;

/**
 * ClassName:springboot_study
 * Description:
 *
 * @Create: 2024/7/5 10:38
 * @author: likl
 * @e-mail: likl1102@foxmail.com
 * @QQ: 2514927731
 */
//@Component
@Data
@ConfigurationProperties(prefix = "servers")
// 开启校验
@Validated
public class ServletConfig {
    private String ipAddress;
    @Max(value = 8888,message = "最大值不能好过超过8888")
    private int port;
    private long timeout;
    @DurationUnit(ChronoUnit.HOURS)
    private Duration serverTimeOut;
    @DataSizeUnit(DataUnit.MEGABYTES)
    private DataSize dataSize;
}
